package za.co.felixsol.sf.dxf.reader.entity;

import java.util.List;

import za.co.felixsol.sf.dxf.reader.DxfEntities;
import za.co.felixsol.sf.dxf.reader.DxfEntry;

public abstract class DxfEntity {

	private DxfEntry entityType;
	private DxfEntities dxfEntities;
	private List<DxfEntry> parameters;

	public DxfEntity(DxfEntities dxfEntities, DxfEntry entityType,
			List<DxfEntry> parameters) {
		super();
		this.entityType = entityType;
		this.dxfEntities = dxfEntities;
		this.parameters = parameters;
	}

	public List<DxfEntry> getParameters() {
		return parameters;
	}
	
	protected DxfEntry findDxfEntry(Integer code) {
		if (this.parameters != null) {
			for (DxfEntry entry : parameters) {
				if (code.equals(entry.getCode())) {
					return entry;
				}
			}
		}
		return null;
	}

	public DxfEntry getEntityType() {
		return entityType;
	}
	
	public DxfEntry getLayer() {
		return findDxfEntry(8);
	}

	public DxfEntry getVisibility() {
		return findDxfEntry(60);
	}
	
	public boolean isVisible() {
		DxfEntry entry = getVisibility();
		if (entry != null) {
			if (entry.getValue() != null) {
				if (entry.getValue().equals("1")) {
					return false;
				}
			}
		}
		return true;
	}
	
	
}
